package com.huawei.M01.iterator.M05;

/**
 * 传递枕头
 *
 * @author 111
 */
public class PassThePillow {
    public int passThePillow(int n, int time) {
        if (time  / (n - 1) % 2 == 0) {
            return 1 + time % (n - 1);
        }else {
            return n - (time % (n - 1));
        }
    }

    public static void main(String[] args) {
        System.out.println(new PassThePillow().passThePillow(4, 5));
    }
}
